<?php

namespace App\View\Components\System;

use App\Facade\AppContext;
use Illuminate\View\Component;

class User extends Component
{
    public $lis;
    public $value;
    public $showAll;

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($value = 0, $showAll = true, $group = '')
    {
        $this->value = $value;
        $this->showAll = $showAll;
        $query = \App\Models\System\User::query()->whereRaw('find_in_set(?,hospital_ids)', [AppContext::hospitalId()]);
        if (!empty($group)) {
            $query->where('group_code', '=', $group);
        }
        $this->lis = $query->get();
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return view('components.system.user');
    }
}
